package com.ruibang.glass.material.controller.cp;

import com.ruibang.glass.material.domain.req.bcp.BcpProductsOutReq;
import com.ruibang.glass.material.domain.req.bcp.ManageBCPOutInReq;
import com.ruibang.glass.material.entity.bcp.MaterialBcpProductsInInfo;
import com.ruibang.glass.material.entity.bcp.MaterialBcpProductsOut;
import com.ruibang.glass.material.entity.cp.MaterialCPProductsOut;
import com.ruibang.glass.material.service.cp.MaterialCPProductsOutService;
import com.teaming.cloud.framework2.common.model.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *成品出库管理 前端控制器
 * </p>
 *
 * @author mameng
 * @since 2024-02-05
 */
@RestController
@RequestMapping("/api/material/cp/product/out")
@Api(value = "成品出库管理", tags = {"成品出库管理"})
public class MaterialCPProductOutController {


    @Autowired
    private MaterialCPProductsOutService materialBcpProductsOutService;

    @PostMapping("/list")
    @ApiOperation(value = "成品出库管理列表查询", response = ResultBody.class)
    public ResultBody getPageList(@RequestBody BcpProductsOutReq bcpProductsOutReq) {
        return ResultBody.success(materialBcpProductsOutService.getPage(bcpProductsOutReq));
    }

    @PostMapping("/add")
    @ApiOperation(value = "新增成品出库", response = ResultBody.class)
    public ResultBody addMaterialBcpProductsInInfo(@RequestBody MaterialCPProductsOut materialBcpProductsInInfo) {
        materialBcpProductsOutService.addMaterialCPProductsOut(materialBcpProductsInInfo);
        return ResultBody.success();
    }

    @PostMapping("/update")
    @ApiOperation(value = "跟新审批", response = ResultBody.class)
    public ResultBody updateMaterialBcpProductsInInfo(@RequestBody MaterialCPProductsOut materialBcpProductsInInfo) {
        materialBcpProductsOutService.updateMaterialCpProductsInInfoList(materialBcpProductsInInfo);
        return ResultBody.success();
    }

    @GetMapping("/processNotice/{businessId}")
    @ApiOperation(value = "成品监听", response = ResultBody.class)
    public ResultBody processNotice(@PathVariable("businessId") String businessId) {
        materialBcpProductsOutService.processNotice(businessId);
        return ResultBody.success();
    }

    @GetMapping("/getOne/{id}")
    @ApiOperation(value = "跟新审批", response = ResultBody.class)
    public ResultBody getMaterialBcpProductsInInfo(@PathVariable("id") String id) {
        MaterialCPProductsOut byId = materialBcpProductsOutService.getMaterialMaterialCPProductsOutById(id);
        return ResultBody.success(byId);
    }

    @PostMapping("/getBondList")
    @ApiOperation(value = "出入库流水列表", response = ResultBody.class)
    public ResultBody getBondList(@RequestBody ManageBCPOutInReq manageBCPOutInReq) {
        return ResultBody.success(materialBcpProductsOutService.getPage(manageBCPOutInReq));
    }

    @PostMapping("/removeByIds")
    @ApiOperation(value = "删除", response = ResultBody.class)
    public ResultBody removeByIds(@RequestBody MaterialBcpProductsInInfo materialBcpProductsInInfo) {
        materialBcpProductsOutService.removeByIds(materialBcpProductsInInfo.getIds());
        return ResultBody.success();
    }

    @PostMapping("/updateItemHouse")
    @ApiOperation(value = "跟新出库状态", response = ResultBody.class)
    public ResultBody updateItemHouse(@RequestBody MaterialCPProductsOut materialBcpProductsInInfo) {
        materialBcpProductsOutService.updateItemHouse(materialBcpProductsInInfo);
        return ResultBody.success();
    }


}
